package flow;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class FlowBean implements Writable {

    //上传流量
    private long upFlow;
    //下载流量
    private long downFlow;
    //流量总和
    private long sumFlow;

    public FlowBean() {
    }

    public FlowBean(long upFlow, long downFlow) {
        this.upFlow = upFlow;
        this.downFlow = downFlow;
        this.sumFlow = upFlow + downFlow;
    }

    public long getUpFlow() {
        return upFlow;
    }

    public FlowBean setUpFlow(long upFlow) {
        this.upFlow = upFlow;
        return this;
    }

    public long getDownFlow() {
        return downFlow;
    }

    public FlowBean setDownFlow(long downFlow) {
        this.downFlow = downFlow;
        return this;
    }

    public long getSumFlow() {
        return sumFlow;
    }

    public FlowBean setSumFlow(long sumFlow) {
        this.sumFlow = sumFlow;
        return this;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(upFlow);
        out.writeLong(downFlow);
        out.writeLong(sumFlow);

    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.upFlow = in.readLong();
        this.downFlow = in.readLong();
        this.sumFlow = in.readLong();

    }

    @Override
    public String toString() {
        return "" + this.upFlow + "\t" + this.downFlow + "\t" + this.sumFlow;
    }
}
